import { Message } from 'element-ui';
import { deepClone, formatMoney } from '../../../common/utils.js';
const list = [
    {
        accountId: '6289370912',
        accountName: '6月7号上传3500人账单',
        accountSettle: '23465.76',
        serviceRate: '5%',
        accountTotal: '3612314.23',
        status: '已完成'
    },
    {
        accountId: '5289370912',
        accountName: '6月7号上传3500人账单',
        accountSettle: '23465.76',
        serviceRate: '5%',
        accountTotal: '23523948203.12',
        status: '执行中'
    }
]

const listD = [
    {
        componyName:'滴滴（重庆）线下公司',
        dsize: 10,
        dpage: 1,
        dPageTotal: 20,
        dCount: 1000,
        dScale: 50,
        dAmount: 10000,
        dList: [{
            name: '张三',
            phone: '185421123',
            idCard: '342342199504013422',
            openAccount: '622123124123',
            actualAmount: '1214123.12',
            settleTime: '20190625 00:19:20',
            tax: '284.23',
            insurance: '123.23',
            totalAmount: '1231421.32'
        },{
            name: '李四',
            phone: '185421123',
            idCard: '342342199504013422',
            openAccount: '622123124123',
            actualAmount: '1214123.12',
            settleTime: '20190625 00:19:20',
            tax: '284.23',
            insurance: '123.23',
            totalAmount: '1231421.32'
        }]
    },{
        componyName:'滴滴（上海）线下公司',
        dsize: 10,
        dpage: 1,
        dPageTotal: 20,
        dCount: 1000,
        dScale: 50,
        dAmount: 10000,
        dList: [{
            name: '张三',
            phone: '185421123',
            idCard: '342342199504013422',
            openAccount: '622123124123',
            actualAmount: '1214123.12',
            settleTime: '20190625 00:19:20',
            tax: '284.23',
            insurance: '123.23',
            totalAmount: '1231421.32'
        },{
            name: '李四',
            phone: '185421123',
            idCard: '342342199504013422',
            openAccount: '622123124123',
            actualAmount: '1214123.12',
            settleTime: '20190625 00:19:20',
            tax: '284.23',
            insurance: '123.23',
            totalAmount: '1231421.32'
        }]
    },{
        componyName:'滴滴（北京）线下公司',
        dsize: 10,
        dpage: 1,
        dPageTotal: 20,
        dCount: 1000,
        dScale: 50,
        dAmount: 10000,
        dList: [{
            name: '张三',
            phone: '185421123',
            idCard: '342342199504013422',
            openAccount: '622123124123',
            actualAmount: '1214123.12',
            settleTime: '20190625 00:19:20',
            tax: '284.23',
            insurance: '123.23',
            totalAmount: '1231421.32'
        },{
            name: '李四',
            phone: '185421123',
            idCard: '342342199504013422',
            openAccount: '622123124123',
            actualAmount: '1214123.12',
            settleTime: '20190625 00:19:20',
            tax: '284.23',
            insurance: '123.23',
            totalAmount: '1231421.32'
        }]
    }
]

export default {
    data() {
        return {
            sizeModel: 'small',
            labelWidth: '100px',
            activeNames: ['1'],
            param: {
                size: 10,
                page: 1,
                serialNum: '',
                keyWord: '',
                status: '',
            },
            total: 0,
            pageNum: [10,20,50],
            list: [],
            multipleSelection: [],
            isShowDialog: false,
            dialogList:[],
            dialogInfo:{
                count:100000,
                freezeAmount:43242342,
                balance: 123123
            }
        }
    },

    components: {},

    computed: {

    },
    filters: {
        filterMoney(val) {
            return formatMoney(val);
        }
    },
    methods: {
        search() {
            this.list = Array(10).fill(list[this.param.page - 1]);
            this.list = this.list.map((item, index) => {
                let listItem = deepClone(item);
                listItem.accountId += index;
                return listItem;
            })

            this.total = 20;
        },
        searchReset() {
            this.param.page = 1;
            this.param = {
                size: 10,
                page: 1,
                serialNum: '',
                keyWord: '',
                status: '',
            };
            this.search();
        },
        handleSizeChange(val) {
            this.param.size = val;
            this.search();
        },
        pageSearch(val) {
            this.param.page = val;
            this.search()
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
            // console.log(val);
        },
        getDetails(info) {
            this.isShowDialog = true;
            let list = deepClone(listD)
            this.searchD(list  || undefined);
        },
        searchD(list) {
            if (!list) {
                return;
            }

            list.map((item,index) => {
                item.dList = Array(10).fill(listD[index].dList[list[index].dpage - 1]);
                // console.log(item.dList[1])
                return item;
            })
            this.dialogList = list;
            // this.dPageTotal = 20;
        },
        pageSearchD(val,type) {
            let pageData = this.dialogList.map(item => {
                if(item.componyName == type){
                    item.dpage = val;
                    return item
                }
                return item;
            });
            this.dialogList = pageData;
            this.searchD(pageData);
        },
        handleSizeChangeD(val) {
            this.dialog.size = val;
            this.searchD();
        },
        // 给表头添加背景颜色
        getRowClass ({row, column, rowIndex, columnIndex}) {
            if (rowIndex === 0) {
                return 'height: 50px'
            } else {
                return ''
            }
        },
    },
    mounted(){
        this.getDetails();
    }
}
